package mylibrary.extend.ePropsTest;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public abstract class BaseAction extends Action {

	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		String logStr = "execute(...) : ";
		ActionForward forward = null;

		System.out.println("This is the execute in BaseAction.");
		
		try {
			executeBefore(mapping, form, request, response);

			forward = executeAction(mapping, form, request, response);
			
			executeAfter(request);
		} catch (Exception e) {

		} finally {
		}
		return forward;
	}

	protected void executeBefore(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		System.out.println("This is the executeBefore in BaseAction with 4.");
		
		executeBefore(form, request, response);
	}

	protected void executeBefore(ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		System.out.println("This is the executeBefore in BaseAction with 3.");
		
		executeBefore(request, response);
	}

	protected void executeBefore(HttpServletRequest request, HttpServletResponse response) throws Exception {
		// Real stuff goes here
		System.out.println("This is the executeBefore in BaseAction with 2.");
	}

	protected abstract ActionForward executeAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception;

	protected void executeAfter(HttpServletRequest request) throws Exception {
	}
}
